load("js/luaclient.js");
/**
 *
 * @type {{REQ_LOGIN_HTML_URL: string, REQ_ACCONT_INFO_URL: string, REQ_BILL_DATA_LIST_URL: string, REQ_BILL_DATA_DETAIL_URL: string, REQ_UNBILL_DATA_URL: string, REQ_UNBILL_DATA_DETAIL_URL: string}}
 */
var beijing_urls = {
    // 北京信用卡登录页
    REQ_LOGIN_HTML_URL :"https://card.bankofbeijing.com.cn/bobbank/",
    // 北京信用卡，基本信息
    REQ_ACCONT_INFO_URL : "https://card.bankofbeijing.com.cn/bobbank/acctmng/acctqry",
    // 北京银行信用卡账单信息数据
    REQ_BILL_DATA_LIST_URL:"https://card.bankofbeijing.com.cn/bobbank/billmng/bill/index",
    // 北京银行信用卡账单列表数据
    REQ_BILL_DATA_DETAIL_URL:"https://card.bankofbeijing.com.cn/bobbank/billmng/bill/pages",
    // 北京银行信用卡未账单信息数据
    REQ_UNBILL_DATA_URL:"https://card.bankofbeijing.com.cn/bobbank//billmng/unbill/index",
    // 北京银行信用卡未账单列表数据
    REQ_UNBILL_DATA_DETAIL_URL:"https://card.bankofbeijing.com.cn/bobbank/billmng/unbill/pages",
}
/**
 * 采集请求信息
 * @type {{}}
 */
var collectHtmlData = {
    /**
     * 采集信用卡基本信息
     */
    collectBillInfoData : function () {
        var accountInfoURL = beijing_urls.REQ_ACCONT_INFO_URL;
        var accountData = new HashMap();
        accountData.put("menuId", "2000");
        accountData.put("pmenuId", "m2");
        var accountInfoHtml = ajax_post(accountInfoURL, accountData);
        // logger.info("帐户页面:{}",accountInfo);
        storeDataToFile(context, accountInfoHtml, "accountInfo.html");
        context.put("account_info",accountInfoHtml);
    },
    /**
     * 采集信用卡账单数据
     * @param singleMonth
     * @param billDay
     */
    collectBillDetails:function (singleMonth,billDate,doneType,nowMonth) {
        var req_bill_data_list_url = "";
        var postData = new HashMap();
        postData.put("cardSeq", "1");
        postData.put("currency", "L");
        if(equals("UNDONE",doneType)){
            // 未出账单
            req_bill_data_list_url = beijing_urls.REQ_UNBILL_DATA_URL;
            // 每月账单
            var undoneBillHtml = ajax_post(req_bill_data_list_url, postData);
            storeDataToFile(context,undoneBillHtml,  doneType +"_billdata.html");
            context.put(doneType +"_billdata",undoneBillHtml)
        }else {
            req_bill_data_list_url = beijing_urls.REQ_BILL_DATA_LIST_URL;
            var sinMonth = singleMonth.replaceAll("-", "");
            postData.put("year", sinMonth);
            postData.put("date", sinMonth);
            postData.put("stmtdate", nowMonth.replaceAll("-", ""));
            // 每月账单
            var billDateEveryHtml = ajax_post(req_bill_data_list_url, postData);
            storeDataToFile(context,billDateEveryHtml, "bill_" + doneType +"_"+ singleMonth + ".html");
            context.put("bill_" + doneType +"_"+ singleMonth,billDateEveryHtml)
        }
    },
    /**
     * 采集信用卡账单详情
     */
    collectBillDetail:function (singleMonth,doneType) {
        var req_bill_data_detail_url = "";
        if(equals("UNDONE",doneType)){
            req_bill_data_detail_url = beijing_urls.REQ_UNBILL_DATA_DETAIL_URL;
            // 每月账单明细
            var billDateShoppingJson = ajax_post(req_bill_data_detail_url, new HashMap());
            storeDataToFile(context,billDateShoppingJson, "bill_" + doneType +"_Shopping.json");
            context.put("bill_" + doneType +"_Shopping",billDateShoppingJson);
        }else {
            req_bill_data_detail_url = beijing_urls.REQ_BILL_DATA_DETAIL_URL;
            // 每月账单明细
            var billDateShoppingJson = ajax_post(req_bill_data_detail_url, new HashMap());
            storeDataToFile(context,billDateShoppingJson, "bill_" + doneType +"_"+ singleMonth + "Shopping.json");
            context.put("bill_" + doneType +"_"+ singleMonth + "Shopping",billDateShoppingJson);
        }
    },

}